$(function(){
    
  $('.cityInfo>div').click(function(){
    let hef;
    if($(this).index() == 0){
      hef = 'getgsshop';
    }else if($(this).index() == 1){
      hef = 'getgsshoparea';
    }else{
       hef = null;
    }

    $.ajax({
        type : "get",
        url  : `http://chst.vip:1234/api/${hef}`
     }).then((res)=>{
         var arr = res.result;
         let html=''
         if(hef == 'getgsshop'){
             arr.forEach(item=>{
                 html+=`
                 <li shopId=${item.shopId}>${item.shopName}</li>
                 `
             })
         }else{
             arr.forEach(item=>{
                 html+=`
                 <li areaId=${item.areaId}>${item.areaName}</li>
                 `
             })
         }
         $('.info').html(html);
$('.info>li').click(function(){
    let areaId = $(this).attr('areaId')
    let shopId = $(this).attr('shopId')
    console.log(areaId,shopId);
    if (shopId && !areaId) {
        areaId = 0
        $.ajax({
            type : "get",
            url  : `http://chst.vip:1234/api/getgsproduct?shopid=${shopId}&areaid=${areaId}`
            }).then((res)=>{
    
        })
    }else if (!shopId && areaId) {
        shopId = 0
        $.ajax({
            type : "get",
            url  : `http://chst.vip:1234/api/getgsproduct?shopid=${shopId}&areaid=${areaId}`
            }).then((res)=>{
    
        })
    }else{
        
        $.ajax({
            type : "get",
            url  : `http://chst.vip:1234/api/getgsproduct?shopid=${shopId}&areaid=${areaId}`
            }).then((res)=>{
    
        })
    }
    
        
    })
 })

})
})
